﻿using System;
using System.Collections.Generic;
using HR60_PanelSoft.Model.BaseModel;
using HR60_PanelSoft.Tools;

namespace HR60_PanelSoft.Model
{
    //GC: 增加场景类型属性。Scene @s1
	/// <summary>
	/// 场景对象
	/// </summary>
	public class Scene : RefModel
    {
		/// <summary>
		/// 名称
		/// </summary>
		public string name = "";

		/// <summary>
		/// 操作集合
		/// </summary>
		public List<SceneEvent> events = new List<SceneEvent>();

		/// <summary>
		/// 灯光场景区域号
		/// </summary>
		public int lampAreaId = -1;

		/// <summary>
		/// 灯光场景号
		/// </summary>
		public int lampSceneId = -1;

        /* s1:增加场景类型  */
        /// <summary>
        /// 场景类型
        /// </summary>
        public SceneType type = SceneType.Auto;
        /* s1 */

		/// <summary>
		/// 查找设备的控制事件
		/// </summary>
		/// <param name="uuid"></param>
		/// <returns></returns>
		public SceneEvent findEventByDevice(string uuid)
		{
			foreach(SceneEvent ev in events)
			{
				if (ev.device == uuid)
				{
					return ev;
				}
			}
			return null;
		}

		// find by uuid
		public static Scene find(string uuid)
		{
			foreach (Scene scene in Proj.currentProj.scenes)
			{
				if (scene.uuid == uuid)
					return scene;
			}
			return null;
		}

        public static int findSceneNum(string uuid)
        {
            if (StringUils.isBlack(uuid))
                return 0;

            int i=0;
            foreach (Scene scene in Proj.currentProj.scenes)
			{
                i++;
				if (scene.uuid == uuid)
					return i;
			}
			return 0;
        }

    }
}
